{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Title: #Diving Board LCCI"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Difficulty: #Easy"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Category Title: #LCCI"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Tag Slug: #array #math"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Name Translated: #数组 #数学"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Solution Name: divingBoard"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Translated Title: #跳水板"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Translated Content:\n",
    "<p>你正在使用一堆木板建造跳水板。有两种类型的木板，其中长度较短的木板长度为<code>shorter</code>，长度较长的木板长度为<code>longer</code>。你必须正好使用<code>k</code>块木板。编写一个方法，生成跳水板所有可能的长度。</p>\n",
    "\n",
    "<p>返回的长度需要从小到大排列。</p>\n",
    "\n",
    "<p><strong>示例 1</strong></p>\n",
    "\n",
    "<pre><code><strong>输入：</strong>\n",
    "shorter = 1\n",
    "longer = 2\n",
    "k = 3\n",
    "<strong>输出：</strong> [3,4,5,6]\n",
    "<strong>解释：</strong>\n",
    "可以使用 3 次 shorter，得到结果 3；使用 2 次 shorter 和 1 次 longer，得到结果 4 。以此类推，得到最终结果。</code></pre>\n",
    "\n",
    "<p><strong>提示：</strong></p>\n",
    "\n",
    "<ul>\n",
    "\t<li>0 &lt; shorter &lt;= longer</li>\n",
    "\t<li>0 &lt;= k &lt;= 100000</li>\n",
    "</ul>\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Description: [diving-board-lcci](https://leetcode.cn/problems/diving-board-lcci/description/)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Solutions: [diving-board-lcci](https://leetcode.cn/problems/diving-board-lcci/solutions/)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "test_cases = []"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "       \n",
    "        if k == 0:\n",
    "            return []\n",
    "        if shorter == longer:\n",
    "            return [shorter*k]\n",
    "        if shorter < longer:\n",
    "            return list(range(shorter*k, longer*k+1, (longer - shorter)))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        if not k:\n",
    "            return []\n",
    "        if shorter==longer:\n",
    "            return [shorter*k]\n",
    "        res=[0]*(k+1)\n",
    "        for i in range(k+1):\n",
    "            res[i]=shorter*(k-i)+longer*i\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        if k == 0:\n",
    "            return []\n",
    "        if shorter == longer:\n",
    "            return [shorter * k]\n",
    "\n",
    "        delta = longer - shorter\n",
    "        return [shorter * k + delta * i for i in range(0, k+1)]\n",
    "\n",
    "        \n",
    "        \n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        result = []\n",
    "        if k == 0:\n",
    "            return result\n",
    "        for i in range(k+1):\n",
    "            result.append(shorter*(k-i)+longer*i)\n",
    "            if shorter == longer:\n",
    "                return result\n",
    "\n",
    "        return result\n",
    "\n",
    "            "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        Diving_boards = []\n",
    "        if shorter == longer == 1 and k != 0:\n",
    "            Diving_boards.append(k)\n",
    "            return Diving_boards\n",
    "        for longer_num in range(k+1):\n",
    "            shorter_num = k - longer_num\n",
    "            diving_board = shorter_num * shorter + longer_num * longer\n",
    "            if diving_board:\n",
    "                Diving_boards.append(diving_board)\n",
    "        return Diving_boards\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        if k==0:\n",
    "            return []\n",
    "        if shorter==longer:\n",
    "            return [shorter * k]\n",
    "        res = [0]*(k+1)\n",
    "        for i in range(k + 1):\n",
    "            res[i] = (longer - shorter) * i + shorter * k\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        if k == 0:\n",
    "            return []\n",
    "        if shorter == longer:\n",
    "            return [shorter * k]\n",
    "        \n",
    "        res = []\n",
    "        for i in range(k, -1, -1):\n",
    "            res.append(shorter * i + longer * (k-i))\n",
    "        \n",
    "        return res\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        b = []\n",
    "        if k == 0:\n",
    "            return b\n",
    "        else:\n",
    "            if shorter == longer:\n",
    "                b = [longer * k]\n",
    "            else:\n",
    "                for i in range(k + 1):\n",
    "                    b.append(longer * i + shorter * (k - i))\n",
    "            return b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        if not k:\n",
    "            return []\n",
    "        if shorter == longer:\n",
    "            return [shorter * k]\n",
    "        res = [0] *(k + 1)\n",
    "        for i in range(k + 1):\n",
    "            res[i] = (shorter * (k - i) + longer * i)\n",
    "        return res\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        if k == 0: \n",
    "            return []\n",
    "        elif shorter == longer:\n",
    "            return [shorter * k]\n",
    "        res = []\n",
    "        for i in range(k + 1): \n",
    "            total_len = (shorter * (k-i)) + (longer * i)\n",
    "            res.append(total_len)\n",
    "        return res\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        if not k:\n",
    "            return []\n",
    "        if shorter == longer:\n",
    "            return [shorter * k]\n",
    "        res = [0] * (k + 1)\n",
    "        for i in range(k + 1):\n",
    "            res[i] = shorter * (k - i) + longer * i\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        if k==0:\n",
    "            return []\n",
    "        a=[]\n",
    "        for i in range(k+1):\n",
    "            x = i*longer+(k-i)*shorter\n",
    "            if a and a[-1]==x:\n",
    "                continue\n",
    "            a.append(x)\n",
    "        return a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        output = []\n",
    "        if k != 0:\n",
    "            if shorter == longer:\n",
    "                output.append(k * shorter)\n",
    "            else:\n",
    "                s_qty, l_qty = k, 0\n",
    "                while s_qty >= 0:\n",
    "                    output.append(s_qty * shorter + l_qty * longer)\n",
    "                    s_qty -= 1\n",
    "                    l_qty += 1\n",
    "        return output\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        if k == 0: # if there is no board\n",
    "            return []\n",
    "        # if the number of shorter board equal to the longer board\n",
    "        elif shorter == longer:\n",
    "            return [shorter*k]\n",
    "        res = []\n",
    "        num_short = k\n",
    "        while num_short >= 0:\n",
    "            total_len = (shorter * num_short) + (longer * (k - num_short))\n",
    "            res.append(total_len)\n",
    "            num_short -= 1\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        if(k == 0):\n",
    "            return []\n",
    "        if(shorter == longer):\n",
    "            return [k*shorter]\n",
    "        \n",
    "        diff = longer - shorter\n",
    "        return [diff*i + k*shorter for i in range(k+1)]\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        if k == 0 : return []\n",
    "        if shorter == longer : return [shorter *k]\n",
    "        res = []\n",
    "        a = shorter *k\n",
    "        for i in range( 0 ,k ) :\n",
    "            res.append(a)\n",
    "            a = a - shorter + longer\n",
    "        res.append( longer * k )\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        return sorted([i * shorter + (k - i) * longer for i in range(k + 1)]) if (k > 0 and longer != shorter) else ([] if k == 0 else [k * shorter])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        my_list = []\n",
    "        if k == 0:\n",
    "            return []\n",
    "        if shorter == longer:\n",
    "            return [k*shorter]\n",
    "        for i in range(k+1):\n",
    "            length = (k-i)*shorter + i*longer\n",
    "            my_list.append(length)\n",
    "        result = list(my_list) \n",
    "        return result\n",
    "\n",
    "        # result.sort()\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        if k == 0: return  []\n",
    "        ans = set()\n",
    "        for i in range(k+1):\n",
    "            ans.add(i*shorter + (k-i)*longer)\n",
    "        \n",
    "        ans  = list(ans)\n",
    "        ans.sort()\n",
    "        return ans\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        result = []\n",
    "        if shorter == longer:\n",
    "            if k == 0:\n",
    "                return []\n",
    "            else:\n",
    "                return [k]\n",
    "        else:\n",
    "            for i in range(0,k+1):\n",
    "                res = i*shorter + (k-i)*longer\n",
    "                result.append(res)\n",
    "        return sorted(result)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        from sortedcontainers import SortedList\n",
    "        ans = SortedList()\n",
    "        for i in range(k + 1 if k > 0 else 0):\n",
    "            l = shorter * i + longer * (k - i)\n",
    "            if l not in ans:\n",
    "                ans.add(l) \n",
    "        return list(ans)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        # 可能会超时\n",
    "        # 用set\n",
    "        if k == 0:\n",
    "            return []\n",
    "        remain = k\n",
    "        theSet = set()\n",
    "        for i in range(k+1):\n",
    "            e = shorter * remain + longer * (k-remain)\n",
    "            theSet.add(e)\n",
    "            remain -= 1\n",
    "        ans = []\n",
    "        for e in theSet:\n",
    "            ans.append(e)\n",
    "        ans.sort()\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:    \n",
    "        if k == 0:\n",
    "            return []\n",
    "        \n",
    "        ans_set = set()\n",
    "        for i in range(k+1):\n",
    "            length = i * shorter + (k-i) * longer\n",
    "            ans_set.add(length)\n",
    "        \n",
    "        ans_list = list(ans_set)\n",
    "        ans_list.sort()\n",
    "        return ans_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        a=set()\n",
    "        if k==0:\n",
    "            return []\n",
    "        shorter,longer=sorted([shorter,longer])\n",
    "        for i in range(k+1):\n",
    "            a.add(shorter*i+longer*(k-i))\n",
    "        return sorted(a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        ret = set()\n",
    "        for i in range(0, k + 1):\n",
    "            ret.add(i * shorter + (k - i) * longer)\n",
    "        ret = list(ret)\n",
    "        ret.sort()\n",
    "        if 0 in ret:\n",
    "            ret.remove(0)\n",
    "        return ret"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        ans = set()\n",
    "        if k==0:\n",
    "            return []\n",
    "        for i in range(k+1):\n",
    "            ans.add(shorter*i+longer*(k-i))\n",
    "        ans = list(ans)\n",
    "        ans.sort()\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        if k == 0:\n",
    "            return []\n",
    "        res = set()\n",
    "        for i in range(0,k+1):\n",
    "            t = i * longer + (k - i)*shorter\n",
    "            res.add(t)\n",
    "        res = list(res)\n",
    "        res.sort()\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        # 短的用i块，长的用k-i块\n",
    "        if k==0:return []\n",
    "        hashset=set()\n",
    "        for i in range(k+1):\n",
    "            hashset.add(i*shorter+(k-i)*longer)\n",
    "        return sorted(hashset)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        if(k == 0):\n",
    "            return []\n",
    "        \n",
    "        result = set()\n",
    "        for i in range(k + 1):\n",
    "            result.add(shorter*i + longer*(k-i) )\n",
    "\n",
    "        result = list(result)\n",
    "        result.sort()\n",
    "        return  result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        return sorted(set(shorter*k + (longer-shorter)*i  for i in range(k+1))) if k > 0 else []"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        return sorted(set(shorter*k + (longer-shorter)*i  for i in range(k+1))) if k > 0 else []"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        s = set()\n",
    "        if k == 0: return []\n",
    "        if shorter == longer: return [longer*k]\n",
    "        for i in range(k):\n",
    "            s.add(i*shorter + (k-i)*longer)\n",
    "        s.add(shorter*k)\n",
    "        s.add(longer*k)\n",
    "        return sorted(s)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        numset = set()\n",
    "        if k == 0:\n",
    "            return list()\n",
    "        for i in range(k + 1):\n",
    "            numset.add(shorter * i + longer * (k - i))\n",
    "        lst = list(numset)\n",
    "        lst.sort()\n",
    "        return lst\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter, longer, k):\n",
    "        a=set()\n",
    "        if k==0:\n",
    "            return []\n",
    "        for i in range(0,k+1):\n",
    "            j=k-i\n",
    "            a.add(shorter*i+longer*j)\n",
    "        b=list(a)\n",
    "        b.sort()\n",
    "        return b\n",
    "\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        ans = set()\n",
    "        if k == 0:\n",
    "            return []\n",
    "        for x in range(k + 1):\n",
    "            y = k - x\n",
    "            tmp = x * shorter + y * longer\n",
    "            ans.add(tmp)\n",
    "        ret = list(ans)\n",
    "        ret.sort()\n",
    "        return ret\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        ans = set()\n",
    "        if k == 0:\n",
    "            return list(ans)\n",
    "        for i in range(k, -1, -1):\n",
    "            j = k-i\n",
    "            ans.add(shorter*i + longer*j)\n",
    "        return sorted(ans)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        ans = set()\n",
    "        if k == 0:\n",
    "            return []\n",
    "        for i in range(0,k+1):\n",
    "            ans.add(shorter * (k-i) + longer *(i))\n",
    "\n",
    "        ret = list(ans)\n",
    "        ret.sort()\n",
    "        return ret"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        if k==0:\n",
    "            return []\n",
    "        d1=set()\n",
    "        for i in range(k+1):\n",
    "            d1.add(shorter*(k-i)+longer*i)\n",
    "        l1=list(d1)\n",
    "        l1.sort()\n",
    "        return l1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        if k == 0:\n",
    "            return []\n",
    "        \n",
    "        li = set()\n",
    "\n",
    "        for i in range(k+1):\n",
    "            num = i*shorter + (k-i)*longer\n",
    "            if num not in li:\n",
    "                li.add(num)\n",
    "        li = list(li)\n",
    "        li.sort()\n",
    "        # print(li)\n",
    "        return li\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        tl = []\n",
    "        if k == 0:\n",
    "            return tl\n",
    "        for i in range(0,k+1):\n",
    "            tl.append(k*longer-(longer-shorter)*i)\n",
    "        return sorted(list(set(tl)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        # 两种怎么都比三种好做吧？\n",
    "        if k == 0:\n",
    "            return []\n",
    "        l = []\n",
    "        for i in range(k+1):\n",
    "            l.append(i*shorter+(k-i)*longer)\n",
    "        return sorted(list(set(l)))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        tl = []\n",
    "        if k == 0:\n",
    "            return tl\n",
    "        for i in range(0,k+1):\n",
    "            tl.append(k*longer-(longer-shorter)*i)\n",
    "        return sorted(list(set(tl)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        res = set()\n",
    "        if k == 0:\n",
    "            return []\n",
    "        for i in range(0, k+1):\n",
    "            res.add(i * shorter + (k - i) * longer)\n",
    "\n",
    "        res = sorted(res)\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        if k == 0:\n",
    "            return []\n",
    "        snum = k\n",
    "        lnum = 0\n",
    "        res = []\n",
    "        while snum >= 0:\n",
    "            l = snum * shorter + lnum * longer\n",
    "            res.append(l)\n",
    "            snum -= 1\n",
    "            lnum += 1\n",
    "        return sorted(list(set(res)))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        ans = set()\n",
    "        if k == 0:\n",
    "            return list(ans)\n",
    "        for i in range(k+1):\n",
    "            j = k-i\n",
    "            ans.add(shorter*i + longer*j)\n",
    "        return sorted(ans)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        if k == 0:\n",
    "            return []\n",
    "        return sorted(set([shorter * (k - i) + longer * i for i in range(k + 1)]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        if k == 0:return []\n",
    "        result = set()\n",
    "        for i in range(k+1):\n",
    "            result.add(shorter*i + longer*(k-i))\n",
    "        s = list(result)\n",
    "        s.sort()\n",
    "        return s"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        if k == 0:\n",
    "            return []\n",
    "        ans=[]\n",
    "        for i in range(k+1):\n",
    "            temp = (k-i)*shorter+i*longer\n",
    "            ans.append(temp)\n",
    "        ans =list(set(ans))\n",
    "        ans.sort()\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        if k==0:\n",
    "            return []\n",
    "        result = []\n",
    "        for i in range(k):\n",
    "            result.append(i*shorter+(k-i)*longer)\n",
    "        result.append(k*shorter)\n",
    "        return sorted(list(set(result)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        # 组合数\n",
    "        # shorter有0到k块，longer是0到k块\n",
    "        if k == 0:\n",
    "            return []\n",
    "        ans = set()\n",
    "        for i in range(k+1):\n",
    "            board = i * longer + (k - i) * shorter\n",
    "            ans.add(board)\n",
    "        return sorted(list(ans))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        if k == 0:\n",
    "            return []\n",
    "        res_set = set()\n",
    "        for i in range(k + 1):\n",
    "            val = shorter * (k - i) + longer * i\n",
    "            res_set.add(val)\n",
    "        return sorted(list(res_set))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> list[int]:\n",
    "        return sorted(list(set([longer*i+shorter*(k-i) for i in range(k+1)]))) if k!=0 else []"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        ans=[]\n",
    "        if k == 0:\n",
    "            return []\n",
    "        for i in range(0,k+1):\n",
    "            ans.append(shorter*i+longer*(k-i))\n",
    "        return sorted(set(ans))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        if k==0:\n",
    "            return []\n",
    "        ans=[]\n",
    "        for i in range(k+1):\n",
    "            tmp=i*shorter+(k-i)*longer\n",
    "            ans.append(tmp)\n",
    "        ans=list(set(ans))\n",
    "        ans.sort()\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        if k ==0:\n",
    "            return []\n",
    "        i = 0\n",
    "        aas = []\n",
    "        while i<=k:\n",
    "            a = i * shorter\n",
    "            b = (k-i)*longer\n",
    "            aas.append(a+b)\n",
    "            i+=1\n",
    "        abs =set(aas)\n",
    "        a = list(abs)\n",
    "        a.sort()\n",
    "        return a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        if not k:\n",
    "            return []\n",
    "        de_duplicate = set()\n",
    "        for i in range(k+1):\n",
    "            de_duplicate.add(shorter*i+longer*(k-i))\n",
    "        return sorted(list(de_duplicate))\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "    #     self.s = shorter\n",
    "    #     self.l = longer\n",
    "    #     return list(self.dfs(k, set()))\n",
    "        \n",
    "    # def dfs(self,k,last_length_set):\n",
    "    #     if not k:\n",
    "    #         return last_length_set\n",
    "    #     k-=1\n",
    "    #     new_set = {length+self.l for length in last_length_set} | {length+self.s for length in last_length_set} if last_length_set else {self.l, self.s}\n",
    "    #     return self.dfs(k, new_set)\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "     sum=[]\n",
    "     for i in range(k+1):\n",
    "        outcome=i * shorter + (k - i) * longer\n",
    "        print(i,outcome)\n",
    "        sum.append(i*shorter+(k-i)*longer)\n",
    "     if k==0:sum=[]\n",
    "     sum=set(sum)\n",
    "     sum=list(sum)\n",
    "     sum.sort()\n",
    "     return sum"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        if k == 0:\n",
    "            return []\n",
    "        if shorter == longer:\n",
    "            return[k*shorter]\n",
    "        \n",
    "        ans = list(set([shorter * i + longer * (k - i) for i in range(k+1)]))\n",
    "        ans.sort()\n",
    "        return ans\n",
    "    \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        if k == 0:\n",
    "            return []\n",
    "        ans = set()\n",
    "        for i in range(k + 1):\n",
    "            ans.add(shorter * i + longer * (k - i))\n",
    "        return sorted(list(ans))\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        res = []\n",
    "        if k == 0:\n",
    "            return res\n",
    "        for i in range(k+1):\n",
    "            res.append(shorter*i)\n",
    "        for i in range(k+1):\n",
    "            res[k-i]+= longer*i\n",
    "        res = list(set(res))\n",
    "        print(res)\n",
    "        res.sort()\n",
    "        print(res)\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        result = []\n",
    "        exists = {}\n",
    "        for count in range(k + 1):\n",
    "            value = longer * count + shorter * (k - count)\n",
    "            if value and value not in exists:\n",
    "                result.append(value)\n",
    "                exists[value] = True\n",
    "        return result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        if k == 0:\n",
    "            return []\n",
    "        dic = set()\n",
    "        s = shorter * k\n",
    "        dic.add(s)\n",
    "        for i in range(k):\n",
    "            s += longer - shorter\n",
    "            dic.add(s)\n",
    "        return sorted(dic)\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        import queue\n",
    "        q = queue.PriorityQueue()\n",
    "        ch = set()\n",
    "\n",
    "        result = []\n",
    "        if k == 0:\n",
    "            return result\n",
    "\n",
    "        for i in range(0, k + 1):\n",
    "            length = shorter * i + (k - i) * longer\n",
    "            if length not in ch:\n",
    "                q.put(length)\n",
    "                ch.add(length)\n",
    "\n",
    "\n",
    "        \n",
    "        while q.qsize() > 0:\n",
    "            result.append(q.get())\n",
    "\n",
    "        return result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        result = []\n",
    "        if k ==0:\n",
    "            return result\n",
    "        seen = set()\n",
    "        def solve(k):\n",
    "            for i in range(k+1):\n",
    "                ans = shorter*(k-i)+longer*(i)\n",
    "                if ans not in seen:\n",
    "                    seen.add(ans)\n",
    "                    result.append(shorter*(k-i)+longer*(i))\n",
    "        solve(k)\n",
    "\n",
    "        return result\n",
    "            \n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        diff = longer-shorter\n",
    "\n",
    "        if not k:\n",
    "            return []\n",
    "        \n",
    "        b_lens = set()\n",
    "\n",
    "        curr_b_len = k * shorter\n",
    "        for _ in range(k+1):\n",
    "            b_lens.add(curr_b_len)\n",
    "            curr_b_len += diff\n",
    "        \n",
    "        ans = list(b_lens)\n",
    "        ans.sort()\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        my_list = set()\n",
    "        if k == 0:\n",
    "            return []\n",
    "        for i in range(k+1):\n",
    "            length = i*shorter + (k-i)*longer\n",
    "            my_list.add(length)\n",
    "        result = list(my_list)\n",
    "        result.sort()\n",
    "        return result\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        import queue\n",
    "        q = queue.PriorityQueue()\n",
    "        ch = set()\n",
    "\n",
    "        result = []\n",
    "        if k == 0:\n",
    "            return result\n",
    "\n",
    "        for i in range(0, k + 1):\n",
    "            length = shorter * i + (k - i) * longer\n",
    "            if length not in ch:\n",
    "                q.put(length)\n",
    "                ch.add(length)\n",
    "\n",
    "\n",
    "        \n",
    "        while q.qsize() > 0:\n",
    "            result.append(q.get())\n",
    "\n",
    "        return result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        if k == 0:\n",
    "            return []\n",
    "        temp = set()\n",
    "        for i in range(k+1):\n",
    "            temp.add((i*longer)+(k-i)*(shorter))\n",
    "        return sorted(list(temp))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        diff = longer-shorter\n",
    "\n",
    "        if not k:\n",
    "            return []\n",
    "        \n",
    "        b_lens = set()\n",
    "\n",
    "        curr_b_len = k * shorter\n",
    "        for _ in range(k+1):\n",
    "            b_lens.add(curr_b_len)\n",
    "            curr_b_len += diff\n",
    "        \n",
    "        ans = list(b_lens)\n",
    "        ans.sort()\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        ans = set()\n",
    "        if k == 0:\n",
    "            return []\n",
    "        for i in range(k, -1, -1):\n",
    "            length = shorter*i+longer*(k-i)\n",
    "            if length not in ans:\n",
    "                ans.add(length)\n",
    "        ans = sorted(list(ans))\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        if k==0:\n",
    "            return []\n",
    "        a=set()\n",
    "        for i in range(k+1):\n",
    "            a.add(i*shorter+(k-i)*longer)\n",
    "        return sorted(a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        nums = set()\n",
    "        for i in range(k + 1):\n",
    "            nums.add(i * shorter + (k - i) * longer)\n",
    "        \n",
    "        if k is 0:\n",
    "            return []\n",
    "        return sorted(list(nums))\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        if k == 0:\n",
    "            return []\n",
    "        res = set()\n",
    "        for i in range(k, -1, -1):\n",
    "            res.add(shorter*i + longer*(k-i))\n",
    "        return sorted(list(res))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        return sorted(set([i * shorter + (k - i) * longer for i in range(k + 1)])) if k > 0 else []"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        if k == 0:\n",
    "            return []\n",
    "        lens = set()\n",
    "        for i in range(k+1):\n",
    "            l = i*shorter + (k-i)*longer\n",
    "            lens.add(l)\n",
    "        return sorted(list(lens))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        diff = longer-shorter\n",
    "        res = set()\n",
    "        total = shorter*k\n",
    "        for i in range(k+1):\n",
    "            res.add(total+i*diff)\n",
    "        return sorted(list(res)) if k!=0 else []\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def divingBoard(self, shorter: int, longer: int, k: int) -> List[int]:\n",
    "        b = []\n",
    "        if k == 0:\n",
    "            return b\n",
    "        for i in range(k + 1):\n",
    "            b.append(shorter * i + longer * (k - i))\n",
    "        result = []\n",
    "        b = set(b)\n",
    "        for j in b:\n",
    "            result.append(j)\n",
    "        result.sort()\n",
    "        return result"
   ]
  }
 ],
 "metadata": {},
 "nbformat": 4,
 "nbformat_minor": 2
}
